package com.webshooter.encoder;

import com.webshooter.entity.Entity;
import javax.json.Json;
import javax.json.JsonBuilderFactory;
import javax.json.JsonObjectBuilder;

public class EntityEventUtil {

    public static JsonObjectBuilder createEntityJsonObject(Entity entity, String type) {
        JsonBuilderFactory factory = Json.createBuilderFactory(null);
        JsonObjectBuilder builder = factory.createObjectBuilder()
                .add("type", type)
                .add("name", entity.name)
                .add("x", entity.pos.x)
                .add("y", entity.pos.y)
                .add("gameLogicState", entity.gameLogicState.toString())
                .add("moveState", entity.moveState.toString())
                .add("angle", entity.angle)
                .add("hitpoints", entity.hitpoints);
        return builder;
    }
}
